﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="../../Scripts/jquery-1.11.1.js"></script>
    <script src="../../Scripts/ejq.js"></script>
    <title>基本的数据绑定</title>
    <script>

        $(function () {

            //申明模版引擎的作用域
            var model = $ejqApp.module("ng-app");
            //控制器操作
            model.controller("ctr1", function ($scope, $app) {

                $scope.model = { name: "张三" }

                var appObj = $app.getObj();

                //给当前控制器name注册事件实现双向绑定
                appObj.on("click", "#btnBind", function () {

                    //更改model
                    $scope.model.name = $("#txtName").val();
                    $ejqApp.apps.bind();
                })
            });
       
            //初始化 
            $ejqApp.apps.bind();

        })
    </script>
    <meta charset="utf-8" />
</head>
<body ng-app="ng-app">
    <div ng-controller="ctr1">
        <h1>标题:{{model.name}}</h1>
        <input id="txtName" value="{{model.name}}" />
        <input type="button" id="btnBind" value="更改标题" />
    </div>
</body>
</html>
